package service

import (
	"bilinadmin/internal/conf"
	"bilinadmin/pkg/log"
	"bilinadmin/pkg/lueerror"
)

// Service 逻辑处理层
type Service struct {
	logger log.Factory
	cfg    *conf.Config
}

var service *Service

// InitService 初始化逻辑处理对象
func InitService(logger log.Factory, cfg *conf.Config) {
	service = &Service{
		logger: logger,
		cfg:    cfg,
	}
}

// GetService 获得逻辑层基础定义
func GetService() *Service {
	return service
}

// 错误 parse
func parseLueerror(err error) lueerror.LueError {
	if err != nil {
		lueErr, ok := err.(lueerror.LueError)
		if ok {
			return lueErr
		} else {
			return lueerror.DbErr(err)
		}
	}
	return nil
}
